package com.yixuan.mt.common.mapper;

import com.yixuan.mt.common.entity.EventsMysql;
import com.yixuan.mt.common.entity.EventsRedis;
import com.yixuan.mt.common.request.EventsMysqlRequest;
import com.yixuan.mt.common.request.EventsRedisRequest;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EventsMapper {

    @Insert("insert into events_mysql (name, url, database_table, username, password) values (#{name}, #{url}, #{databaseTable}, #{username}, #{password})")
    void insertMysqlEvents(EventsMysqlRequest eventsMysqlRequest);

    @Insert("insert into events_redis (name, host, port, password) values (#{name}, #{host}, #{port}, #{password})")
    void insertRedisEvents(EventsRedisRequest eventsRedisRequest);

    @Delete("delete from events_mysql where name = #{name}")
    void deleteMysqlEvents(String name);

    @Delete("delete from events_redis where name = #{name}")
    void deleteRedisEvents(String name);

    @Select("select * from events_mysql")
    List<EventsMysql> selectMysqlEvents();

    @Select("select * from events_redis")
    List<EventsRedis> selectRedisEvents();
}
